if (islogin()) {
    $('#op').click(function () {
        var btn1=[
            {
                text:'发布通知',
                onClick:function () {
                    window.location.href='add_notice.html';
                }
            }
        ];
        var btn2=[
            {
                text:'取消'
            }
        ];
        var groups=[btn1,btn2];
        $$.actions(groups);
    });

    $.post({
        url:'../../requests/teacher/select_notice.php',
        success:function (data) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].class == null) {
                    var dom=" <div class=\"content-block-title\">"+data[i].time+"</div>\n" +
                        "                <div class=\"card\">\n" +
                        "                    <div class=\"card-header\">\n" + data[i].title+
                        "                    </div>\n" +
                        "                    <div class=\"card-content\">\n" +
                        "                        <div class=\"card-content-inner\">\n" +data[i].detail+
                        "                        </div>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"card-footer\">\n" +
                        "                        <div class=\"item-title\">全部班级</div>\n" +
                        "                        <div class=\"item-after\"><button class=\"button del\" id='"+data[i].Id+"'>删除</button></div>\n" +
                        "                    </div>\n" +
                        "                </div>";
                }
                else {
                    var dom=" <div class=\"content-block-title\">"+data[i].time+"</div>\n" +
                        "                <div class=\"card\">\n" +
                        "                    <div class=\"card-header\">\n" + data[i].title+
                        "                    </div>\n" +
                        "                    <div class=\"card-content\">\n" +
                        "                        <div class=\"card-content-inner\">\n" +data[i].detail+
                        "                        </div>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"card-footer\">\n" +
                        "                        <div class=\"item-title\">"+data[i].class+"</div>\n" +
                        "                        <div class=\"item-after\"><button class=\"button del\" id='"+data[i].Id+"'>删除</button></div>\n" +
                        "                    </div>\n" +
                        "                </div>";

                }
                $('.cards-list').append(dom);
            }
        }
    });

    $('.cards-list').on('click','.del',function () {
        var id=$(this).attr('id');
        $.post({
            url:'../../requests/teacher/del_notice.php',
            data:{'id':id},
            success:function (data) {
                if (data == '1') {
                    $$.alert("删除成功！",function () {
                        location.reload(true);
                    });
                }
                else if (data == '0') {
                    $$.alert("删除失败！");
                }
            }
        });
    });
}
else window.location.href='../../index.html';